package com.tedu.controller;

import com.tedu.pojo.SmbmsBill;
import com.tedu.pojo.SmbmsProvider;
import com.tedu.pojo.SmbmsRole;
import com.tedu.pojo.SmbmsUser;
import com.tedu.services.BillRoleServices;
import com.tedu.services.BillServices;
import com.tedu.services.ProviderServices;
import com.tedu.services.UserRoleServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class BillController {
    @Autowired
    BillServices billServices;


    @Autowired
   BillRoleServices billRoleServices;


    //用户管理 全部订单信息
    @RequestMapping("/sys/bill")
    public  String getAllBill(Model model){
        //处理器方法
        List<SmbmsBill> allBill = billServices.getAllBill();
        //发送数据到视图
        model.addAttribute("billList",allBill);
        return "/bill/billlist";
    }

    //添加用户
    @RequestMapping("/sys/billadd")
    public String addUser(Model model){


        List<SmbmsRole> allRole = billRoleServices.getAllRole();
        model.addAttribute("allRole",allRole);
        return "/bill/billadd";

    }

    //订单信息查看
    @RequestMapping("/sys/billview")
    public  String billView(int bid,Model model){
        //调用服务层方法，获取订单信息
        SmbmsBill bill = billServices.getBillById(bid);

        //把用户信息发送给用户
        model.addAttribute("bill",bill);

        //角色信息

        SmbmsRole role =  billRoleServices.getRoleById(bill.getBillcode());
        model.addAttribute("roleName",role.getRolename());
        return "/bill/billview";


    }

}
